<template>
  <div class="body">
    <Head>处理提醒</Head>
    <van-cell-group v-if="type === 'register'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell v-if="utype===1">
        <template #title>
          <span class="cus_title">企业名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">手机号：</span><span class="cus_content">{{info.mobile}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">用户名：</span><span class="cus_content">{{info.username}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">UID：</span><span class="cus_content">{{info.uid}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">最近登录：</span><span class="cus_content">{{info.last_login_time}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">注册时间：</span><span class="cus_content">{{info.reg_time}}（{{info.platform}}）</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">账号状态：</span><span class="cus_content">{{info.status}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'order'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title v-if="utype===1">
          <span class="cus_title">企业名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
        <template #title v-else>
          <span class="cus_title">姓名：</span><span class="cus_content">{{info.fullname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">服务名称：</span><span class="cus_content">{{info.service_name}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">支付状态：</span><span class="cus_content">{{info.status}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">服务金额：</span><span class="cus_content">{{info.service_amount}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">折后金额：</span><span class="cus_content">{{info.service_amount_after_discount}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">优惠折扣：</span><span class="cus_content">{{info.deduct_amount}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">实付金额：</span><span class="cus_content">{{info.amount}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">订单编号：</span><span class="cus_content">{{info.oid}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">下单时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">支付时间：</span><span class="cus_content">{{info.paytime}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">支付方式：</span><span class="cus_content">{{info.payment}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'order_pay'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title v-if="utype===1">
          <span class="cus_title">企业名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
        <template #title v-else>
          <span class="cus_title">姓名：</span><span class="cus_content">{{info.fullname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">服务名称：</span><span class="cus_content">{{info.service_name}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">实付金额：</span><span class="cus_content">{{info.amount}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">订单编号：</span><span class="cus_content">{{info.oid}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">支付时间：</span><span class="cus_content">{{info.paytime}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">支付方式：</span><span class="cus_content">{{info.payment}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'resume_img'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">姓名：</span><span class="cus_content">{{info.fullname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">基本信息：</span><span class="cus_content">{{info.base}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="margin-top: -78px;">照片作品：</span>
          <img :src="info.img" alt="" style="width: 100px;height: 100px;border-radius: 5px">
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">上传时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'company_img'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">公司名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="margin-top: -78px;">企业风采：</span>
          <img :src="info.img" alt="" style="width: 100px;height: 100px;border-radius: 5px">
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">上传时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'account_cancellation'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title v-if="utype===1">
          <span class="cus_title">公司名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
        <template #title v-else>
          <span class="cus_title">姓名：</span><span class="cus_content">{{info.fullname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">联系方式：</span><span class="cus_content">{{info.mobile}}（{{info.username}}）</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">申请时间：</span><span class="cus_content">{{info.cancel_apply_time}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'complaint'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">举报对象：</span><span class="cus_content">{{info.name}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">举报原因：</span><span class="cus_content">{{info.reason_cn}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="line-height: 22px;">举报内容：</span>
          <span class="cus_content" style="line-height: 22px;">{{info.content}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">举报者：</span><span class="cus_content">{{info.mobile}}（uid：{{info.uid}}）</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">举报时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'appeal'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">真实姓名：</span><span class="cus_content">{{info.realname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">申诉描述：</span><span class="cus_content">{{info.description}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">联系手机：</span><span class="cus_content">{{info.mobile}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">申诉时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'recommendation'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">类型：</span><span class="cus_content">{{info.type_cn}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">内容：</span><span class="cus_content">{{info.content}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">联系手机：</span><span class="cus_content">{{info.mobile}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">提交时间：</span><span class="cus_content">{{info.addtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'resume_audit'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">姓名：</span><span class="cus_content">{{info.fullname}}</span>
          <div class="cus_btn absolute_for_y" @click="jumpShow(info.resume_link)">查看</div>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">基本信息：</span><span class="cus_content">{{info.base}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">手机号：</span><span class="cus_content">{{info.mobile}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">刷新时间：</span><span class="cus_content">{{info.refreshtime}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'job_audit'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">职位名称：</span><span class="cus_content jobname">{{info.jobname}}</span>
          <div class="cus_btn absolute_for_y"  @click="jumpShow(info.job_link)">查看</div>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">企业名称：</span><span class="cus_content">{{info.companyname}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">联系方式：</span><span class="cus_content">{{info.mobile}}（{{info.contact}}）</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">状态：</span><span class="cus_content">{{info.status}}</span>
        </template>
      </van-cell>
    </van-cell-group>
    <van-cell-group v-if="type === 'company_audit'">
      <van-cell>
        <template #title>
          <span class="cus_title">提醒服务：</span><span class="cus_content">{{info.remind_service}}</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">企业名称：</span><span class="cus_content">{{info.companyname}}</span>
          <div class="cus_btn absolute_for_y"  @click="jumpShow(info.company_link)">查看</div>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title">联系方式：</span><span class="cus_content">{{info.mobile}}（{{info.contact}}）</span>
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="margin-top: -78px;">营业执照：</span>
          <img :src="info.license_img" alt="" style="width: 100px;height: 100px;border-radius: 5px;">
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="margin-top: -53px;line-height: 21px;width: 68px">经办人身份证：</span>
          <img :src="info.legal_person_idcard_front_img" alt="" style="width: 100px;height: 100px;border-radius: 5px;margin-left: 13px;">
          <img :src="info.legal_person_idcard_back_img" alt="" style="width: 100px;height: 100px;border-radius: 5px;margin-left: 13px;">
        </template>
      </van-cell>
      <van-cell>
        <template #title>
          <span class="cus_title" style="margin-top: -53px;width: 81px;line-height: 21px;">委托书(函)：</span>
          <img :src="info.proxy_img" alt="" style="width: 100px;height: 100px;border-radius: 5px;">
        </template>
      </van-cell>
    </van-cell-group>

    <div class="bottom clear" v-if="type === 'resume_img' || type === 'company_img' || type === 'account_cancellation' || type === 'complaint' || type === 'resume_audit' || type === 'company_audit' || type === 'job_audit'">
      <div class="l_btn" @click="audit(1)">{{audit_pass}}</div>
      <div class="r_btn" @click="audit(2)">{{audit_no_pass}}</div>
    </div>
    <div class="bottom clear" v-if="type === 'appeal' || type === 'recommendation'">
      <div class="l_btn" style="width: 100%;" @click="audit(1)">{{audit_pass}}</div>
    </div>
    <van-dialog v-model="showReason" title="审核不通过原因" :show-confirm-button="false" :show-cancel-button="false" :closeOnClickOverlay="true">
      <van-form @submit="onSubmitReason">
        <van-field
            v-model="auditReason"
            rows="3"
            autosize
            label=""
            type="textarea"
            placeholder="请填写审核不通过原因"
            :rules="[{ required: true, message: '' }]"
        />
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit" @click="reasonExamine()">提交</van-button>
        </div>
      </van-form>
    </van-dialog>
  </div>
</template>

<script>
import http from '@/utils/http'
import api from '@/api'
import Vue from 'vue'
import { Picker } from 'vant'
Vue.use(Picker)
export default {
  name: "promotionResumeAdd",
  components: {
  },
  data () {
    return {
      type: '', // register 注册通知、 order 订单通知、  order_pay 订单支付成功通知、resume_img 照片作品审核通知、company_img 企业风采审核通知、account_cancellation 账号注销审核通知、complaint 投诉举报通知、appeal 账号申诉通知、recommendation 意见建议通知、resume_audit 简历审核、company_audit 企业认证审核、job_audit 职位审核
      audit_pass : '',
      audit_no_pass : '',
      info: [],
      showReason: false,
      auditReason:'',
      id: 0
    }
  },
  created () {
    this.id = this.$route.query.id
    this.type = this.$route.query.type
    this.getData()
  },
  methods:{
    onSubmitReason () {

    },
    jumpShow (url) {
      location.href = url
    },
    getData(){
      http
          .post(api.processReminder, {id:this.id, type:this.type})
          .then(res => {
            this.info = res.data
            this.utype = res.data.utype
            switch (this.type) {
              case 'resume_audit':
              case 'company_audit':
              case 'job_audit':
              case 'resume_img':
              case 'company_img':
                this.audit_pass = '审核通过'
                this.audit_no_pass = '不通过'
                break
              case 'account_cancellation':
                this.audit_pass = '备份'
                this.audit_no_pass = '处理'
                break
              case 'complaint':
                this.audit_pass = '属实'
                this.audit_no_pass = '不属实'
                break
              case 'appeal':
              case 'recommendation':
                this.audit_pass = '处理'
                break
            }
          })
          .catch(() => {})
    },
    audit(audit){
      if (audit === 2)
      {
        if (this.type === 'resume_audit' || this.type === 'company_audit' || this.type === 'job_audit')
        {
          this.showReason = true
          return false
        }else {
          this.reasonExamine()
        }
      }else
      {
        this.examine()
      }
    },
    examine() {
      this.switchExamine(1)
    },
    reasonExamine(){
      this.switchExamine(2)
    },
    switchExamine(audit){
      switch (this.type) {
        case 'resume_audit':  // 简历审核
          this.resumeAudit(audit)
          break
        case 'company_audit': // 企业审核
          this.companyAudit(audit)
          break
        case 'job_audit': // 职位审核
          this.jobAudit(audit)
          break
        case 'resume_img': // 照片作品审核
          this.resumeImgAudit(audit)
          break
        case 'company_img': // 企业风采审核
          this.companyImgAudit(audit)
          break
        case 'account_cancellation': // 账号注销
          this.memberCancelApplyBackups(audit)
          break
        case 'complaint': // 投诉举报
          this.doHandler(audit)
          break
        case 'appeal': // 账号申诉
          this.appealHandler()
          break
        case 'recommendation': // 意见建议
          this.recommendation()
          break
        default:
          return false
      }
      this.$router.push("/")
    },
    appealHandler(){
      http
          .post(api.appealHandler, {id:[this.info.id]})
          .then(res => {
            this.$toast.success(res.message)
          })
          .catch(() => {})
    },
    recommendation(){
      http
          .post(api.feedbackHandler, {id:[this.info.id],status:1})
          .then(res => {
            this.$toast.success(res.message)
          })
          .catch(() => {})
    },
    doHandler(action){
      http
          .post(api.tipoffHandler, {id:[this.info.id],status:action})
          .then(res => {
            this.$toast.success(res.message)
          })
          .catch(() => {})
    },
    memberCancelApplyBackups(audit){
      if (audit === 1){
        this.$dialog
            .confirm({
              title: '系统提示',
              message: '确定备份吗?'
            })
            .then(() => {
              http
                  .post(api.memberCancelApplyBackups, {id: this.info.id})
                  .then(res => {
                    this.$toast.success(res.message)
                  })
                  .catch(() => {
                  })
            })
            .catch(() => {
            })
      }else {
        this.$dialog
            .confirm({
              title: '系统提示',
              message: '注销将删除该企业的所有数据，确定注销吗?'
            })
            .then(() => {
              http
                  .post(api.memberCancelApplyHandle, {id: this.info.id})
                  .then(res => {
                    this.$toast.success(res.message)
                  })
                  .catch(() => {
                  })
            })
            .catch(() => {
            })
      }

    },
    companyImgAudit(audit){
      http
          .post(api.companyImgAudit, {id:[this.info.id], audit:audit})
          .then(res => {
            this.$toast.success(res.message)
          })
          .catch(() => {})
    },
    resumeImgAudit(audit){
      http
          .post(api.resumeImgAudit, {id:[this.info.id], audit:audit})
          .then(res => {
            this.$toast.success(res.message)
          })
          .catch(() => {})
    },
    jobAudit(audit){
      if (audit === 2 && this.auditReason === '') {
        return false
      }
      http
          .post(api.jobAudit, {id:[this.info.id], audit:audit, reason:this.auditReason})
          .then(res => {
            this.$toast.success(res.message)
            this.showReason = false
          })
          .catch(() => {})
    },
    resumeAudit(audit){
      if (audit === 2 && this.auditReason === '') {
          return false
      }
      http
          .post(api.resumeAudit, {id:[this.info.id], audit:audit, reason:this.auditReason})
          .then(res => {
            this.$toast.success(res.message)
            this.showReason = false
          })
          .catch(() => {})
    },
    companyAudit(audit){
      if (audit === 2 && this.auditReason === '') {
        return false
      }
      http
          .post(api.companyAudit, {id:[this.info.id], audit:audit, reason:this.auditReason})
          .then(res => {
            this.$toast.success(res.message)
            this.showReason = false
          })
          .catch(() => {})
    }
  }
}
</script>
<style lang="scss" scoped>
.body { background-color: #ffffff;position: absolute;top: 0;left: 0;overflow-y: auto;width: 100%;height: 100%; }
.cus_title { font-size: 28px;color: #999999;width: 155px;display: inline-block; }
.cus_content { font-size: 28px;color: #333333;width: 83% }
.van-hairline--top-bottom::after, .van-hairline-unset--top-bottom::after { border-top: 0; }
.bottom {
  position: absolute;left: 0;bottom: 0;width: 100%;border-top: 1PX solid #f3f3f3;padding: 20px 30px;
  .l_btn {
    float: left;width: 60%;height: 90px;line-height: 90px;text-align: center;border-radius: 8px;font-size: 30px;
    color: #ffffff;background-color: #1787fb;
  }
  .r_btn {
    float: right;width: 36%;height: 90px;line-height: 90px;text-align: center;border-radius: 8px;font-size: 30px;
    color: #ffffff;background-color: #FB8A3E;
  }
}
.cus_btn {
  position: absolute;right: 35px;top: 50%;width: 120px;border: 1PX solid #1787fb;font-size: 24px;
  color: #1787fb;border-radius: 999px;text-align: center;padding: 12px 34px;
}
.jobname {
  width: 55%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>
